const mongoose = require("mongoose");
const { dbPath } = require("../config");

// 连接数据库
mongoose.connect(dbPath);

// 监听数据库连接情况
mongoose.connection.on("error", function () {
  // 数据库连接失败
  console.error("数据库连接失败!");

  process.exit();
});

mongoose.connection.on("open", function () {
  console.log("数据库连接成功!");
});
